#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_BTEClient.h"
#include "NetClient.h"
#include "PackDefine.h"
#include "netPackDefine.h"
#include <QSharedPointer>
#include <QTimer>

#pragma execution_character_set("utf-8")

typedef QSharedPointer<NetClient> NetClientPtr;

class BTEClient : public QMainWindow
{
    Q_OBJECT

public:
    BTEClient(QWidget *parent = Q_NULLPTR);
    ~BTEClient();

protected slots:
    /*net */
    void onConnect();
    void onDisConnect();
    void onNetError();
    void onDataRecv(NetPackPtr ptr);

    /*btn*/
    void on_btnConnect_clicked();
    void on_btnDisConnect_clicked();
    
    void onTimer();

private:    
    void addLog(QString log);
    void updateStatus();

    void sendPack(ushort cmd, const QByteArray &data = QByteArray(), uchar SubDevID = INVAILD_SUB_ID);    
    void sendRealData();

    NetClient m_client;    
    QTimer m_timer;

    Ui::BTEClientClass ui;
};
